package com.heima.user.feign;

import com.heima.apis.user.IUserClient;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.pojos.ApUser;
import com.heima.user.service.ApUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserClient implements IUserClient {
    @Autowired
    private ApUserService apUserService;
    /**
     * 通过
     *
     * @param id
     * @return
     */
    @GetMapping("/api/v1/comment/findById/{id}")
    @Override
    public ResponseResult findUser(@PathVariable("id") Integer id) {
        return apUserService.findById(id);
    }

    /**
     * @param name@return
     */
    @Override
    @PostMapping("/api/v1/comment/findUserById")
    public ApUser findUserByName(@RequestBody String name){
        return apUserService.findUserByName(name);
    }

    /**
     * 根据名字查用户
     * @param userId
     * @return
     */
    @Override
    @PostMapping("/api/v1/comment/findUserByName")
    public ApUser findUserById(@RequestBody Integer userId){
        return apUserService.findUserById(userId);
    }
}
